/* * Copyright 2016 Dmitry Monakhov. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * 03.03.16 16:17 * */ package monakhv.android.samlib; import android.support.test.espresso.UiController; import android.support.test.espresso.ViewAction; import android.view.View; import monakhv.samlib.log.Log; import org.hamcrest.Matcher; /** * Action on View inside RecycleView item * Created by monakhv on 03.03.16. */ class MyViewAction { static ViewAction clickChildViewWithId(final int id) { return new ViewAction() { @Override public Matcher<View> getConstraints() { return null; } @Override public String getDescription() { return "Click on a child view with specified id."; } @Override public void perform(UiController uiController, View view) { View v = view.findViewById(id); if (v != null) { Log.i("TEST","perform click"); v.performClick(); }else { Log.e("TEST","view not found"); } } }; } }